import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    visible: true
    width: 400
    height: 300
    title: "TreeView Example"

    TreeView {
        id: treeView
        width: parent.width
        height: parent.height
        model: treeModel
        columnSpacing: 10

        delegate: RowLayout {
            width: parent.width
            height: 40
            spacing: 10

            Text {
                text: model.display
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignLeft
            }
        }

        // header: Rectangle {
        //     height: 30
        //     color: "lightgray"
        //     border.color: "gray"
        //     Text {
        //         text: "Name"
        //         anchors.centerIn: parent
        //     }
        // }
    }

    Component.onCompleted: {
        var data = [
            "Root",
            "  Child 1",
            "    Grandchild 1",
            "    Grandchild 2",
            "  Child 2",
            "    Grandchild 3",
            "      Great-grandchild 1"
        ]
        treeModel.setupModelData(data)
    }
}
